import routertable from "./routertable";
import React, { Component, Suspense } from 'react';
import { Switch ,Route, Redirect} from 'react-router-dom'
import RC from '../assets/RC.gif'
class RouterView extends Component {
    render() {
        return (
            <Suspense fallback={<img src={RC} alt="" style={{ width: '100%', position: 'fixed', top: '30px' }} />}>
                <Switch>
                    {
                        routertable.map((item, index) => {
                            return (
                                item.from?
                                <Redirect exact from={item.from} to={item.to} key={index}/>:
                                <Route path={item.path} 
                                component={item.component} key={index} />
                            )
                        })
                    }
                </Switch>
            </Suspense>
        );
    }
}

export default RouterView;